package com.cx.mall.user.dao.impl;

import com.cx.mall.jdbc.JdbcUtils;
import com.cx.mall.user.dao.IUserInfoDao;
import com.cx.mall.user.entity.UserInfo;
import org.springframework.stereotype.Component;

import java.util.List;
@Component
public  class UserInfoDaoImpl implements IUserInfoDao {
    @Override
    public void insert(UserInfo userInfo) throws Exception {
        String sql = "INSERT INTO `user_info` VALUES (?,?,?,?,?,?,?,?)";
        Object[] params = {
                userInfo.getId(),
                userInfo.getUsername(),
                userInfo.getPassword(),
                userInfo.getEmail(),
                userInfo.getNickName(),
                userInfo.getNote(),
                userInfo.getCreateTime(),
                userInfo.getStatus()
        };
        JdbcUtils.update(sql,params);
    }
    @Override
    public void update(UserInfo userInfo) throws Exception {
    }
    @Override
    public void deleteById(Object id) throws Exception {
    }
    @Override
    public UserInfo selectById(Object id) throws Exception {
        String sql = "select * from user_info where id = ?";
        return JdbcUtils.queryBean(sql,UserInfo.class,id);
    }
    @Override
    public UserInfo selectOne(Object... params) throws Exception {
        String sql = "select * from user_info where username = ? and status = 0";
        return JdbcUtils.queryBean(sql,UserInfo.class,params);
    }
    @Override
    public List<UserInfo> selectList(Object... params) throws Exception {
        return null;
    }
}